﻿using Abp.Authorization;
using Abp.Localization;
using Abp.MultiTenancy;
using Mt.Site;
using Mt.Site.Core.Authorization;

namespace Mt.Site.Core.DataLogs.Permissions
{
    public class DataLogsPermissionProvider : AuthorizationProvider
    {
        public override void SetPermissions(IPermissionDefinitionContext context)
        {
            var pages = context.GetPermissionOrNull(AppPermissions.Pages) ?? context.CreatePermission(AppPermissions.Pages, L("Pages"));
            var DataLogsManage = pages.CreateChildPermission(DataLogsPermissions.Pages_Manage_DataLogs, L("DataLogs"), multiTenancySides: MultiTenancySides.Tenant);
            DataLogsManage.CreateChildPermission(DataLogsPermissions.Pages_Manage_DataLogs_Create, L("CreateDataLogs"), multiTenancySides: MultiTenancySides.Tenant);
            DataLogsManage.CreateChildPermission(DataLogsPermissions.Pages_Manage_DataLogs_Update, L("UpdateDataLogs"), multiTenancySides: MultiTenancySides.Tenant);
            DataLogsManage.CreateChildPermission(DataLogsPermissions.Pages_Manage_DataLogs_Delete, L("DeleteDataLogs"), multiTenancySides: MultiTenancySides.Tenant);
            DataLogsManage.CreateChildPermission(DataLogsPermissions.Pages_Manage_DataLogs_Query, L("QueryDataLogs"), multiTenancySides: MultiTenancySides.Tenant);
        }

        private static ILocalizableString L(string name)
        {
            return new LocalizableString(name, MtSiteConsts.LocalizationSourceName_Permissions);
        }
    }
}
